#import <MobileCoreServices/MobileCoreServices.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import "EaseRefreshTableViewController.h"
#import "IMessageModel.h"
#import "EaseOptionsMessageCell.h"
#import "EaseMessageModel.h"
#import "EaseBaseMessageCell.h"
#import "EaseMessageTimeCell.h"
#import "EaseChatToolbar.h"
#import "EaseLocationViewController.h"
#import "EMCDDeviceManager+Media.h"
#import "EMCDDeviceManager+ProximitySensor.h"
#import "UIViewController+HUD.h"
#import "EaseSDKHelper.h"
@interface EaseAtTarget : NSObject
@property (nonatomic, copy) NSString    *userId;
@property (nonatomic, copy) NSString    *nickname;
- (instancetype)initWithUserId:(NSString*)userId andNickname:(NSString*)nickname;
@end
typedef void(^EaseSelectAtTargetCallback)(EaseAtTarget*);
@class EaseMessageViewController;
@protocol EaseMessageViewControllerDelegate <NSObject>
@optional
- (UITableViewCell *)messageViewController:(UITableView *)tableView
                       cellForMessageModel:(id<IMessageModel>)messageModel;
- (CGFloat)messageViewController:(EaseMessageViewController *)viewController
           heightForMessageModel:(id<IMessageModel>)messageModel
                   withCellWidth:(CGFloat)cellWidth;
- (void)messageViewController:(EaseMessageViewController *)viewController
 didReceiveHasReadAckForModel:(id<IMessageModel>)messageModel;
- (BOOL)messageViewController:(EaseMessageViewController *)viewController
        didSelectMessageModel:(id<IMessageModel>)messageModel;
- (void)messageViewController:(EaseMessageViewController *)viewController
    didSelectAvatarMessageModel:(id<IMessageModel>)messageModel;
- (void)messageViewController:(EaseMessageViewController *)viewController
            didSelectMoreView:(EaseChatBarMoreView *)moreView
                      AtIndex:(NSInteger)index;
- (void)messageViewController:(EaseMessageViewController *)viewController
          didSelectRecordView:(UIView *)recordView
                 withEvenType:(EaseRecordViewType)type;
- (void)messageViewController:(EaseMessageViewController *)viewController
               selectAtTarget:(EaseSelectAtTargetCallback)selectedCallback;
@end
@protocol EaseMessageViewControllerDataSource <NSObject>
@optional
- (id)messageViewController:(EaseMessageViewController *)viewController
                  progressDelegateForMessageBodyType:(EMMessageBodyType)messageBodyType;
- (void)messageViewController:(EaseMessageViewController *)viewController
               updateProgress:(float)progress
                 messageModel:(id<IMessageModel>)messageModel
                  messageBody:(EMMessageBody*)messageBody;
- (NSString *)messageViewController:(EaseMessageViewController *)viewController
                      stringForDate:(NSDate *)date;
- (id<IMessageModel>)messageViewController:(EaseMessageViewController *)viewController
                           modelForMessage:(EMMessage *)message;
- (BOOL)messageViewController:(EaseMessageViewController *)viewController
   canLongPressRowAtIndexPath:(NSIndexPath *)indexPath;
- (BOOL)messageViewController:(EaseMessageViewController *)viewController
   didLongPressRowAtIndexPath:(NSIndexPath *)indexPath;
- (BOOL)messageViewControllerShouldMarkMessagesAsRead:(EaseMessageViewController *)viewController;
- (BOOL)messageViewController:(EaseMessageViewController *)viewController
shouldSendHasReadAckForMessage:(EMMessage *)message
                         read:(BOOL)read;
- (BOOL)isEmotionMessageFormessageViewController:(EaseMessageViewController *)viewController
                                    messageModel:(id<IMessageModel>)messageModel;
- (EaseEmotion*)emotionURLFormessageViewController:(EaseMessageViewController *)viewController
                                      messageModel:(id<IMessageModel>)messageModel;
- (NSArray*)emotionFormessageViewController:(EaseMessageViewController *)viewController;
- (NSDictionary*)emotionExtFormessageViewController:(EaseMessageViewController *)viewController
                                        easeEmotion:(EaseEmotion*)easeEmotion;
- (void)messageViewControllerMarkAllMessagesAsRead:(EaseMessageViewController *)viewController;
@end
@interface EaseMessageViewController : EaseRefreshTableViewController<UINavigationControllerDelegate, UIImagePickerControllerDelegate, EMChatManagerDelegate, EMCDDeviceManagerDelegate, EMChatToolbarDelegate, EaseChatBarMoreViewDelegate, EMLocationViewDelegate,EMChatroomManagerDelegate, EaseMessageCellDelegate>
@property (weak, nonatomic) id<EaseMessageViewControllerDelegate> delegate;
@property (weak, nonatomic) id<EaseMessageViewControllerDataSource> dataSource;
@property (strong, nonatomic) EMConversation *conversation;
@property (nonatomic) NSTimeInterval messageTimeIntervalTag;
@property (nonatomic) BOOL deleteConversationIfNull; 
@property (nonatomic) BOOL scrollToBottomWhenAppear; 
@property (nonatomic) BOOL isViewDidAppear;
@property (nonatomic) NSInteger messageCountOfPage; 
@property (nonatomic) CGFloat timeCellHeight;
@property (strong, nonatomic) NSMutableArray *messsagesSource;
@property (strong, nonatomic) UIView *chatToolbar;
@property(strong, nonatomic) EaseChatBarMoreView *chatBarMoreView;
@property(strong, nonatomic) EaseFaceView *faceView;
@property(strong, nonatomic) EaseRecordView *recordView;
@property (strong, nonatomic) UIMenuController *menuController;
@property (strong, nonatomic) NSIndexPath *menuIndexPath;
@property (strong, nonatomic) UIImagePickerController *imagePicker;
@property (nonatomic) BOOL isJoinedChatroom;
-(void)messageOption:(id<IMessageModel>)model index:(NSInteger)index;
- (instancetype)initWithConversationChatter:(NSString *)conversationChatter
                           conversationType:(EMConversationType)conversationType;
-(void)checkFirstSend;
- (void)tableViewDidTriggerHeaderRefresh;
- (void)sendTextMessage:(NSString *)text;
- (void)sendTextMessage:(NSString *)text withExt:(NSDictionary*)ext;
- (void)sendImageMessage:(UIImage *)image;
- (void)sendLocationMessageLatitude:(double)latitude
                          longitude:(double)longitude
                         andAddress:(NSString *)address;
- (void)sendVoiceMessageWithLocalPath:(NSString *)localPath
                             duration:(NSInteger)duration;
- (void)sendVideoMessageWithURL:(NSURL *)url;
- (void)sendFileMessageWith:(EMMessage *)message;
- (void)addMessageToDataSource:(EMMessage *)message
                     progress:(id)progress;
- (void)showMenuViewController:(UIView *)showInView
                 andIndexPath:(NSIndexPath *)indexPath
                  messageType:(EMMessageBodyType)messageType;
- (BOOL)shouldSendHasReadAckForMessage:(EMMessage *)message
                                 read:(BOOL)read;
@end
